package com.jeedlelabs.tubess;

import java.io.InputStream;
import java.util.ArrayList;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.util.Log;

class ImageDownloader extends AsyncTask<String, Void, Bitmap> {
   
    private ArrayList<Item> data;
    private VideoGridViewAdapter adapter;
    public ImageDownloader(VideoGridViewAdapter adapt, ArrayList<Item> i) {
    
    	this.adapter = adapt;
    	if (i == null)
    		this.data = new ArrayList<Item>();
    	else
    		this.data = i;
    }
    
    protected Bitmap doInBackground(String... urls) {
        Bitmap mIcon11 = null;
        try {
        for (String s : urls){
        	InputStream in = new java.net.URL(s).openStream();
            mIcon11 = BitmapFactory.decodeStream(in);
            data.add(new Item(mIcon11,"hola"));
        }
        
        } catch (Exception e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }
        return mIcon11;
    }

    protected void onPostExecute(Bitmap result) {
    	adapter.notifyDataSetChanged();
    }
}